import webapp2
from lib.toolbox import Sessions
from lib.toolbox import Render
from lib.toolbox import Sites


class AddPage(Render):

    def get(self, url):
        
        s = Sessions()

        if s.ValidSession(self.request.cookies.get("uid", '')):

            self.render("add.base.html")

        else:

            self.redirect('/')

        
      

    def post(self, url):

        url = self.request.get('url')
        name = self.request.get('name')
        rate = self.request.get('rate')
        xpath = self.request.get('xpath')

        a = Sites(
                url = str(url),
                name = str(name),
                rate = int(rate),
                xpath = str(xpath)
                )
        a.put()